import {
	createRouter,
	createWebHashHistory
} from 'vue-router'

import Home from '@/views/Home.vue'

let routes = [{
	path: '/',
	name: 'Home',
	component: Home,
	meta: {
		title: '首页',
		keepAlive: false
	}
},
{
	path: '/404',
	name: '404',
	component: () => import( /* webpackChunkName: "about",webpackPrefetch:true */ '@/views/common/404.vue'),
	meta: {
		title: '404',
		keepAlive: false
	}
},
{
	path: "/:pathMath(.*)", // 此处需特别注意置于最底部
	redirect: "/404"
}]


const routerContext = require.context('./', true, /\.js$/);

routerContext.keys().forEach(route => {

	// 如果是根目录的 index.js 、transition-extend.js不处理
	if (['./index.js', './transition-animation.js'].includes(route)) {
		return
	}
	const routerModule = routerContext(route)

	// 兼容 import export 和 require module.export 两种规范
	routes = routes.concat(routerModule.default || routerModule)
})



let router = createRouter({
	history: createWebHashHistory(),
	routes
})

export default router
